package com.lifesting.wfs.Runtime.addon;

import org.eclipse.emf.ecore.impl.EObjectImpl;

import com.lifesting.wfs.Runtime.IExecutorFactory;
import com.lifesting.wfs.Runtime.NodeExecutor;
import com.lifesting.wfs.Runtime.Router;
import com.lifesting.wfs.Runtime.RuntimeFactory;
import com.lifesting.wfs.gd.GdPackage;
import com.lifesting.wfs.gd.Node;
import com.lifesting.wfs.gd.Transition;

public class MinorExecutorFactoryImpl extends EObjectImpl implements
		IExecutorFactory {

	@Override
	public NodeExecutor createExecutor(Node node) {
		NodeExecutor executor = null;
		int cls_id = node.eClass().getClassifierID();
		switch (cls_id)
		{
		case GdPackage.START:
			executor = RuntimeFactory.eINSTANCE.createStartExecutor();
			break;
		case GdPackage.END:
			executor = RuntimeFactory.eINSTANCE.createEndExecutor();
			break;
		case GdPackage.FORK:
			executor = RuntimeFactory.eINSTANCE.createForkExecutor();
			break;
		case GdPackage.JOIN:
			executor = RuntimeFactory.eINSTANCE.createJoinExecutor();
			break;
		case GdPackage.TASK_RUNNER:
			executor = RuntimeFactory.eINSTANCE.createTaskRunnerExecutor();
			break;
		case GdPackage.AUTO:
			executor = RuntimeFactory.eINSTANCE.createAutoRunExecutor();
			break;
		
		default:
				throw new RuntimeException("Unkown node "+node);
		}
		executor.setNode(node);
		return executor;
	}

	@Override
	public Router createRouter(Transition transition) {
		Router r = RuntimeFactory.eINSTANCE.createRouter();
		r.setTransition(transition);
		return r;
	}

}
